package com.fywsy.fyweb.strategy;

import com.fywsy.fyweb.entity.SendItem;
import com.fywsy.fyweb.utils.RestTemplateUtil;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;

/**
 * 游戏后台实现类
 * 注解gameId对应数据库游戏id
 * 注解GongnengMethod对应数据库功能id
 */
@Component
@GameId(23)
public class AFengbaoGameStrategy extends BaseGameStrategy {
    public static final String URL = "http://111.170.174.196:804/htss/gzs.php";

    /**
     * 平台币：
     * qu: 2
     * gb: 12
     * sqm: 51boshao.com
     * usr: m66666
     * pay:
     * num: 1
     * item: 26402
     * type: 9
     *
     * 钻石
     * qu: 2
     * gb: 12
     * sqm: 51boshao.com
     * usr: m66666
     * pay: 321
     * num: 1
     * item: 26402
     * type: 7
     * @param item
     * @return
     */
    @GongnengMethod(2301)
    public String pay(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("sqm", "diyao88");

        if("1".equals(item.itemId)) {
            params.add("type", "9");
            params.add("gb", item.number);
        } else {
            params.add("type", "7");
            params.add("pay", item.number);
        }

        params.add("qu", item.qufu);
        params.add("usr", item.uid);

        return RestTemplateUtil.sendPostForm(URL, params);
    }

    /**
     * qu: 2
     * gb: 12
     * sqm: 51boshao.com
     * usr: m66666
     * pay: 321
     * num: 131
     * item: 5
     * type: 8
     * @param item
     * @return
     */
    @GongnengMethod(2302)
    public String mail(SendItem item) {
        MultiValueMap<String,String> params = new LinkedMultiValueMap<>();
        params.add("sqm", "diyao88");
        params.add("type", "8");

        params.add("num", item.number);
        params.add("item", item.itemId);
        params.add("qu", item.qufu);
        params.add("usr", item.uid);

        return RestTemplateUtil.sendPostForm(URL, params);
    }



    @GongnengMethod(9)
    public String clear(SendItem item) {
        System.out.println("清除成功");
        return "清除成功";
    }

    public static void main(String[] args) {
        SendItem item = new SendItem();
        item.itemId = "5";
        item.number = "123";
        item.qufu = "2";
        item.uid = "m66666";
        System.out.println(new AFengbaoGameStrategy().mail(item));
    }
}

